<template>
  <el-date-picker
    v-model="date"
    type="datetimerange"
    range-separator="至"
    :start-placeholder="placeholder + '开始时间'"
    :end-placeholder="placeholder + '结束时间'"
    :default-time="['00:00:00', '23:59:59']"
    v-bind="$attrs"
    align="right">
  </el-date-picker>
</template>

<script>
  export default{
    name:'myTimePicker',
    props:{
      placeholder:{
        type:String,
        default:''
      },
      startTime:{
        type:String,
      },
      endTime:{
        type:String,
      }
    },
    computed:{
      date:{
        get(){
          return (this.startTime && this.endTime) ? [new Date(this.startTime),new Date(this.endTime)] : null
        },
        set(val){
          this.$emit('update:startTime',val ? this.parseTime(val[0]):null)
          this.$emit('update:endTime',val ? this.parseTime(val[1]): null)
        }
      }
    },
    data(){
      return{

      }
    }
  }
</script>

<style>
</style>
